#ifndef AILIBOT_BASE_H
#define AILIBOT_BASE_H

#include <ros/ros.h>
#include <starrobot_msgs/Velocities.h>
#include <tf2_ros/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>
#include <tf2/LinearMath/Quaternion.h>
#include <geometry_msgs/TransformStamped.h>
#include <chrono>
#include <ros/callback_queue.h>
#include <ros/time.h>
#include <tf/transform_broadcaster.h>
class starrobotBase
{
public:
    starrobotBase();
    

private:
	void PublisherRawVel(const ros::TimerEvent&e_);
	void velCallback(const starrobot_msgs::Velocities& vel);
    ros::NodeHandle nh_;

    std::string sub_name_;
    std::string pub_name_;
    std::string baseType;
    std::string getOdomMode_;
    std::string tf_frame_id_name_;
    std::string tf_child_frame_id_name_;

    std::string odom_frame_id_name_;
    std::string odom_child_frame_id_name_;
    
    ros::Publisher odom_publisher_;
    ros::Subscriber velocity_subscriber_;
    tf2_ros::TransformBroadcaster odom_broadcaster_;
    ros::Timer timer_RawVel;
    ros::Time last_vel_time_;
    geometry_msgs::TransformStamped odom_trans;
    geometry_msgs::Quaternion odom_quat;
    nav_msgs::Odometry odom;
    
	//float steering_angle_;
	float linear_velocity_x_;
	float linear_velocity_y_;
	float angular_velocity_z_;
	float encoder_data_x_,encoder_data_y_,encoder_angle_z_;
	float motor_encoder1_old,motor_encoder2_old;
	float motor_encoder3_old,motor_encoder4_old;
	float motor_encoder1_inc,motor_encoder2_inc;
	float motor_encoder3_inc,motor_encoder4_inc;
	float linear_scale_correction_;
	float angular_scale_wheel_;
    float lr_wheels_distance_;
    float fr_wheels_distance_;
    float Coefficient;          //轮子左右中间值和前后中间值的和
	float vel_dt_;
	float x_pos_;
	float y_pos_;
	float heading_;
	bool pub_encoder_odom_tf_;
	bool is_sub_node_;
	bool is_timer;
	bool resetOdom;
};

#endif
